package com.api.gbhg.lbj.action;

import com.api.gbhg.lbj.util.TestMenu;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lbj
 * @version 1.0
 * @description: TODO
 * @date 2021/5/17 17:52
 */
public class TestMain {
    public static void main(String[] args) {
        TestMenu m = new TestMenu();
        m.setId(1);
        m.setpId(0);
        TestMenu m2 = new TestMenu();
        m2.setId(2);
        m2.setpId(1);
        TestMenu m3 = new TestMenu();
        m3.setId(3);
        m3.setpId(1);
        TestMenu m4 = new TestMenu();
        m4.setId(4);
        m4.setpId(1);

        List<TestMenu> list = new ArrayList<>();
        list.add(m);
        list.add(m2);
        list.add(m3);
        list.add(m4);
        List<String> ls = new ArrayList<>();
        ls.add("1");
//        getIds(list, 1, ls);
//        System.out.println("ls:" + ls+"getIds:"+getIds(list, 0, ls));

        String joinId="2,4,10,11";
        for (int i = 0 ; i<joinId.split(",").length;i++){
            System.out.println("joinId"+joinId.split(",")[i]);
        }
    }
    private static List<String> getIds(List<TestMenu> ms, int id, List<String> ids) {
        for (int i = 0; i < ms.size(); i++) {
            if (ms.get(i).getpId() == id) {
                ids.add(String.valueOf(ms.get(i).getId()));
                getIds(ms, ms.get(i).getId(), ids);
            }
        }
        return ids;

    }


}
